VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} frmBookSheetSelect 
   Caption         =   "Select Book/Sheet(s) for profiling"
   ClientHeight    =   3480
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4935
   OleObjectBlob   =   "frmBookSheetSelect.frx":0000
   StartUpPosition =   1  'CenterOwner
End
Attribute VB_Name = "frmBookSheetSelect"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit

Private mShowSheets As Boolean
Private bookName As String
Private sheetName As String

Public Property Get SheetAndBookSelected() As Boolean
    SheetAndBookSelected = SheetSelected And BookSelected
End Property

Public Property Get BookSelected() As Boolean
    BookSelected = Len(bookName) > 0
End Property
    
Public Property Get SheetSelected() As Boolean
    SheetSelected = Len(sheetName) > 0
End Property
    
Public Property Get SelectedBookName() As String
    SelectedBookName = bookName
End Property

Public Property Get SelectedSheetName() As String
    SelectedSheetName = sheetName
End Property

Public Property Let ShowSheets(showThem As Boolean)
    mShowSheets = showThem
End Property

Private Sub cbobooks_Change()
    If mShowSheets Then
        LoadSheetsFor Workbooks(cbobooks.list(cbobooks.ListIndex))
    End If
End Sub

Private Sub cmdCancel_Click()
    bookName = ""
    Hide
End Sub

Private Sub cmdOK_Click()

    If cbobooks.ListIndex >= 0 Then
        bookName = cbobooks.list(cbobooks.ListIndex)
    End If
    If lstSheets.ListIndex >= 0 Then
        sheetName = lstSheets.list(lstSheets.ListIndex)
    End If
    
    Me.Hide

End Sub

Private Sub UserForm_Activate()

Dim book As Workbook

    lstSheets.Visible = mShowSheets
    lblSheetList.Visible = mShowSheets

    With cbobooks

        For Each book In Workbooks
            .AddItem book.Name
        Next

        .ListIndex = 0

    End With

End Sub

Private Sub LoadSheetsFor(book As Workbook)

Dim sht As Worksheet

    With lstSheets

        .Clear

        For Each sht In book.Worksheets
            .AddItem sht.Name
        Next
    
        .ListIndex = 0
    
    End With

End Sub
